#include "smallwidget.h"
#include "ui_smallwidget.h"

#include <QDebug>
#include <QHBoxLayout>

SmallWidget::SmallWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SmallWidget)
{
    //    ui->setupUi(this);
    this->resize(400,100);
    spin = new QSpinBox(this);
    slider = new QSlider(Qt::Horizontal, this);
    slider->setRange(0, 10);

    // 创建布局对象
    QHBoxLayout* layout = new QHBoxLayout;
    // 将控件添加到布局中
    layout->addWidget(spin);
    layout->addWidget(slider);
    // 将布局设置到窗口中
    setLayout(layout);

    // 添加消息响应
    connect(spin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), slider, &QSlider::setValue);
    connect(slider, &QSlider::valueChanged, spin, &QSpinBox::setValue);

    slider->setValue(5);
}

SmallWidget::~SmallWidget()
{
    delete ui;
}

void SmallWidget::PrintInfo()
{
    qDebug() << "PrintInfo...";
}
